<template>
	<view class="">
		<view class="ffffff mainpadding margin_top" v-for="item in list.data" :key="item.id" @click="selectitem(item.shop_id)">
			<view class="ershiba zhonghei fonweight">{{item.shop.name}}</view>
			<view class="flexbetween margin_top">
				<view class="" style="width: 90%;">
					<view class="flexleft">
						<u-icon name="map"></u-icon>
						<view class="ershil xiaohui margin_left1 xiankuan1">{{item.shop.cityinfo}}{{item.shop.address}}</view>
					</view>
					<view class="flexleft margin_top2">
						<u-icon name="clock"></u-icon>
						<view class="ershil xiaohui margin_left1">营业时间：{{item.shop.yysj}}</view>
					</view>
				</view>
				<!-- 已勾选 -->
				<u-icon name="checkmark-circle-fill" color="#FF9341" size="24" v-if="item.shop_id==listid"></u-icon>
				<!-- 未勾选 -->
				<view class="weixz " v-else></view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				listid:""
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.init()
		},
		methods: {
			selectitem(id){
				if(this.listid==id){
					return false
				}
				uni.$emit("changedp",id)
				uni.navigateBack(1)
			},
			init(isPage, page) {
				let _this = this
				let url = "/api/shopcl/myShopUserIndex"
				httpRequest.request(url, 'GET', {
					page: page || 1,
					limit: _this.limit
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>